package com.zgroup.controllers.admin

import com.zgroup.common.CipherUtils
import com.zgroup.domain.SysUser

class AdminController extends AdminDispatchController {

  def estateService
  def infoReleaseService
  def beforeInterceptor = [action: this.&auth]

  def auth() {
    return super.auth()
  }

  def approveEstate = {
    def user = request[SysUser.REQUEST_USER_INFO]
    def approved = estateService.approve(params.id, params.flag, user)
    render(approved ? "1" : "0")
  }
  def approveInfoRelease = {

    def user = request[SysUser.REQUEST_USER_INFO]

    def approved = infoReleaseService.approve(params.id, params.approveFlag, user,params.approveOption)
    render(params.approveFlag)
  }

  def changePassword = {
    SysUser user = request[SysUser.REQUEST_USER_INFO]
    def dbuser = SysUser.get(user.id)
    dbuser.password = CipherUtils.md5(params.newpwd)
    dbuser.save()
  }

}
